

package cn.shengchao.examstar.share.acl.adapters.clients;

import cn.shengchao.examstar.product.ohs.local.appservice.ProductAppService;
import cn.shengchao.examstar.product.ohs.local.message.ProductDto;
import cn.shengchao.examstar.share.acl.ports.clients.IProductClient;
import cn.shengchao.examstar.share.domain.valobj.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ShareProductClient implements IProductClient {

    @Autowired
    private ProductAppService productAppService;

    @Override
    public Product getProductById(Long productId) {
        ProductDto productDto = productAppService.getProductById(String.valueOf(productId));
        Product product = new Product();
        product.setId(Long.valueOf(productDto.getProductId()));
        product.setName(productDto.getProductName());
        return product;
    }
}
